﻿Imports System.Linq
Imports Equipment.Core
Imports Equipment.DataAccess

Public Class GroupManager
    Public Shared Function GetAllFor(ByVal forUser As IUserInfo) As IEnumerable(Of Group)
        If forUser.IsSuperUser Then
            Return Group.RetrieveAll()
        Else
            Return Group.RetrieveAllBySiteID(forUser.SiteID)
        End If
    End Function

    Public Shared Function GetAllByDepartmentFor(ByVal licationID As Integer, ByVal forUser As IUserInfo) As IEnumerable(Of Group)
        If forUser.IsSuperUser Or forUser.IsSiteAdmin Then
            Return Group.RetrieveAllByDepartmentID(licationID)
        Else
            Return Group.RetrieveAllByDepartmentIDFor(forUser.SiteID, forUser.GroupIDs)
        End If
    End Function

    Public Shared Function GetAllBySiteFor(ByVal siteID As Integer, ByVal forUser As IUserInfo) As IEnumerable(Of Group)
        If forUser.IsSuperUser Or forUser.IsSiteAdmin Then
            Return Group.RetrieveAllBySiteID(siteID)
        Else
            Return Group.RetrieveAllBySiteIDFor(forUser.SiteID, forUser.GroupIDs)
        End If
    End Function
End Class
